import * as types from './types.js'
import { getDicList } from '@/services/service_dictionary'
import { Message } from 'element-ui'

export default {
  namespaced: true,
  state: {
    seriesMap: [],
    productSpecial: []
  },
  mutations: {
    getSeriesMap (state, context) {
      state.seriesMap = context
    },
    getProductSpecial (state, context) {
      state.productSpecial = context
    },
  },
  actions: {
    async dispatchSeriesMap (store, payload) {
      try {
        const res = await getDicList({
          label: 'product_series',
          current: 1,
          size: 99999
        })
        if (res.code == 0) {
          store.commit('getSeriesMap', res.data.records)
        } else {
          Message.warning(res.msg)
        }
      } catch (error) {
        console.log(error);
      }
    },
    async dispatchProductSpecial (store, payload) {
      try {
        const res = await getDicList({
          label: 'product_special',
          current: 1,
          size: 99999
        })
        if (res.code == 0) {
          store.commit('getProductSpecial', res.data.records)
        } else {
          Message.warning(res.msg)
        }
      } catch (error) {
        console.log(error);
      }
    }
  },
  getters: {
  }
}
